<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-stpm v1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <link rel="stylesheet" href="../../css/formSelects-v4.css">
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../js/formSelects-v4.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
			<span class="layui-breadcrumb">
            <a href="javascript:;">首页</a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div style="padding-top: 15px">
    <div class="layui-row layui-col-space15">
        <!--左边-->
        <div class="layui-row layui-col-space15 layui-col-md8">
            <!--测试统计-->
            <!--<div class="layui-col-md12">-->
                <!--&lt;!&ndash;项目列表&ndash;&gt;-->
                <!--<div class="layui-col-md3">-->
                    <!--<div class="layui-card" style="height: 280px;">-->
                        <!--<div class="layui-card-header">-->
                            <!--<h3>项目统计</h3>-->
                        <!--</div>-->
                        <!--<div class="layui-card-body">-->
                            <!--<table class="layui-table" lay-even="" lay-skin="nob">-->
                                <!--<tbody>-->
                                <!--<tr>-->
                                    <!--<td>相机功能的开发</td>-->
                                <!--</tr>-->
                                <!--</tbody>-->
                            <!--</table>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
                <!--&lt;!&ndash;点击项目后的详情&ndash;&gt;-->
                <!--<div class="layui-col-md9">-->
                    <!--<div class="layui-card" style="height: 280px">-->
                        <!--&lt;!&ndash;头部，左右布局&ndash;&gt;-->
                        <!--<div class="layui-card-header">-->
                            <!--<div style="float: left">-->
                                <!--<h3>测试统计</h3>-->
                            <!--</div>-->
                            <!--<div style="float: right">-->
                                <!--<a onclick="xadmin.open('查看所有Bug','../bug/bug-list.html')" class="layui-btn layui-btn-radius layui-btn-xs">-->
                                    <!--<cite title="查看所有Bug">查看所有Bug</cite>-->
                                <!--</a>-->
                            <!--</div>-->
                        <!--</div>-->
                        <!--&lt;!&ndash;主体部分&ndash;&gt;-->
                        <!--<div class="layui-card-body">-->
                            <!--&lt;!&ndash;单独显示所有项目&ndash;&gt;-->
                            <!--<div class="layui-col-md2">-->
                                <!--<ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog" >-->
                                    <!--<li class="layui-col-md12 layui-col-xs6">-->
                                        <!--<a href="javascript:;" class="x-admin-backlog-body" style="height: 180px;display: table-cell;vertical-align: middle;text-align: center">-->
                                            <!--<h3>所有Bug</h3>-->
                                            <!--<p><cite>3</cite></p>-->
                                        <!--</a>-->
                                    <!--</li>-->
                                <!--</ul>-->
                            <!--</div>-->
                            <!--&lt;!&ndash;显示所有项目的情况&ndash;&gt;-->
                            <!--<div class="layui-col-md10">-->
                                <!--<ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog" >-->
                                    <!--<li class="layui-col-md12 layui-col-xs6">-->
                                        <!--<a href="javascript:;" class="x-admin-backlog-body">-->
                                            <!--<h3>未解决</h3>-->
                                            <!--<div class="layui-progress" lay-showpercent="true">-->
                                                <!--<div class="layui-progress-bar" lay-percent="70%"></div>-->
                                            <!--</div>-->
                                        <!--</a>-->
                                    <!--</li>-->
                                    <!--<li class="layui-col-md12 layui-col-xs6">-->
                                        <!--<a href="javascript:;" class="x-admin-backlog-body">-->
                                            <!--<h3>未确认</h3>-->
                                            <!--<div class="layui-progress" lay-showpercent="true">-->
                                                <!--<div class="layui-progress-bar" lay-percent="70%"></div>-->
                                            <!--</div>-->
                                        <!--</a>-->
                                    <!--</li>-->
                                    <!--<li class="layui-col-md12 layui-col-xs6">-->
                                        <!--<a href="javascript:;" class="x-admin-backlog-body">-->
                                            <!--<h3>未关闭</h3>-->
                                            <!--<div class="layui-progress" lay-showpercent="true">-->
                                                <!--<div class="layui-progress-bar" lay-percent="70%"></div>-->
                                            <!--</div>-->
                                        <!--</a>-->
                                    <!--</li>-->
                                <!--</ul>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <!--Bug统计-->
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <h3>Bug统计列表</h3>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="bugTable" lay-filter="bugTable"></table>
                        <!--<script type="text/html" id="barDemo">-->
                            <!--<a class="layui-btn layui-btn-xs" lay-event="confirm">确认</a>-->
                            <!--<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="finish">解决</a>-->
                            <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="close">关闭</a>-->
                            <!--<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">编辑</a>-->
                        <!--</script>-->
                        <!--<script type="text/html" id="processTpl">-->
                            <!--<div class="layui-progress" lay-showpercent="true" style="margin-top: 15px">-->
                                <!--<div class="layui-progress-bar" lay-percent="{{d.projectProcess+'%'}}"></div>-->
                            <!--</div>-->
                        <!--</script>-->
                    </div>
                </div>
            </div>
        </div>
        <!--右边-->
        <div class="layui-row layui-col-space15 layui-col-md4">
            <!--我的代办事项-->
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <div style="float: left">
                            我的代办事项
                        </div>
                        <!--<div style="float: right;">-->
                            <!--<a class="layui-btn layui-btn-sm" onclick="xadmin.open('添加代办','../todo/todo-add.html')">-->
                                <!--<i class="layui-icon" title="添加代办">&#xe654;</i>-->
                            <!--</a>-->
                        <!--</div>-->
                    </div>
                    <div class="layui-card-body ">
                        <table class="layui-hide" id="todoTable"></table>
                    </div>
                </div>
            </div>
            <!--我参与的项目-->
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">我参与的项目</div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="projectTable"></table>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script>
    layui.use(['laydate', 'form', 'laypage', 'layer', 'table', 'element','layedit'], function() {
        var laydate = layui.laydate;
        var form = layui.form;
        var laypage = layui.laypage;
        var layer = layui.layer;
        var table = layui.table;
        var element = layui.element;
        var formSelects = layui.formSelects;
        var layedit=layui.layedit;
        var $=layui.jquery;

        var bugAdd,bugEdit;
        var bugProjectCode,bugPriority;
        var bugId;
        var role;

        laydate.render({
            elem:'#bugEndDate',
            type:'datetime'
        });
        laydate.render({
            elem:'#bugEndDate_edit',
            type:'datetime'
        });
        // layedit.build('bugStep');
        form.on('select(bugProjectCodeSelect)',function (data) {
            bugProjectCode=data.value;
        });
        form.on('select(bugPrioritySelect)',function (data) {
            bugPriority=data.value;
        });
        form.on('select(bugPrioritySelect_edit)',function (data) {
            bugPriority=data.value;
        });

        //Bug列表
        table.render({
            elem:'#bugTable'
            ,cellMinWidth:80
            , height: 300
            ,url: 'http://localhost:8080/bug/mybug' //数据接口
            , title: 'Bug表'
            , page: true //开启分页
            , toolbar: 'default' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
            ,defaultToolbar:['filter', 'exports']
            // , totalRow: true //开启合计行
            ,cols: [[ //表头
                {
                    type: 'radio',
                    fixed: 'left'
                }, {
                    field: 'id',
                    title: 'ID',
                    hide: true,
                }, {
                    field: 'bugPriority',
                    title: '级别',
                    width: '10%',
                    sort: true
                }, {
                    field: 'bugProjectCode',
                    title: '项目代号',
                    width: '20%',
                    minWidth: 100,
                    sort: true
                }, {
                    field: 'bugName',
                    title: 'bug标题',
                    width: '20%',
                    sort: true
                }, {
                    field: 'role',
                    title: 'role',
                    hide: true
                }, {
                    field: 'bugCreater',
                    title: '创建者',
                    width: '10%',
                    sort: true
                }, {
                    field: 'bugAssginedTo',
                    title: '指派给',
                    width: '15%',
                    sort: true
                }, {
                    field: 'bugEndDate',
                    title: '结束时间',
                    width: '15%',
                    sort: true
                },{
                    field: 'bugStatus',
                    title: '状态',
                    width: '10%',
                    sort: true
                },{
                    field: 'bugStep',
                    title: '描述',
                    hide: true
                }
            ]]
            ,done:function (res, curr, count){
                var bugList=res.data;
                if(bugList.length!=0){
                    role=bugList[0].role;
                }
            }
        });

        //监听头工具栏事件
        table.on('toolbar(bugTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id),
                data = checkStatus.data; //获取选中的数据
            switch (obj.event) {
                case 'add':
                    // xadmin.open('提Bug','../bug/bug-add.html');
                    if(role!='测试人员'){
                        layer.msg('添加问题单只能由测试完成，当前角色：'+role, {
                            icon: 5,
                            time:2000
                        });
                    }else {
                        $.ajax({
                            url: 'http://localhost:8080/project/code',
                            contentType: "application/x-www-form-urlencoded",
                            type: 'GET',
                            xhrFields: {
                                withCredentials: true
                            },
                            success: function (data) {
                                if (data.status == "success") {
                                    var data = data.data;
                                    for (var i = 0; i < data.length; i++) {
                                        $('#bugProjectCode').append("<option value=" + data[i].projectCode + ">" + data[i].projectCode + "</option>")
                                    }
                                    form.render('select');
                                } else {
                                    layer.msg(data.data.errMsg, {
                                        icon: 5,
                                        time: 1000
                                    });
                                }
                            }
                        });
                        formSelects.data('assginedToSelect', 'server', {
                            url: 'http://localhost:8080/user/developer',
                            keyword: 'name'
                        });
                        formSelects.render();
                        bugAdd = layer.open({
                            type: 1,
                            title: '添加问题单',
                            area: ['600px', '500px'],
                            content: $('#bug_add')
                        });
                    }
                    break;
                case 'update':
                    if(role!='测试人员'){
                        layer.msg('添加问题单只能由测试完成，当前角色：'+role, {
                            icon: 5,
                            time:2000
                        });
                    }else {
                        if (data.length === 0) {
                            layer.msg('请选择一行');
                        } else if (data.length > 1) {
                            layer.msg('只能同时编辑一个');
                        } else {
                            // xadmin.open('修改选中的Bug','../bug/bug-edit.html');
                            $("#bugProjectCode_edit").val(data[0].bugProjectCode);
                            $("#bugName_edit").val(data[0].bugName);
                            $("#bugStep_edit").val(data[0].bugStep);
                            bugId = data[0].id;
                            formSelects.data('assginedToSelect_edit', 'server', {
                                url: 'http://localhost:8080/user/developer',
                                keyword: 'name'
                            });
                            formSelects.render();
                            bugEdit = layer.open({
                                type: 1,
                                title: '修改问题单',
                                area: ['600px', '500px'],
                                content: $('#bug_edit')
                            });
                        }
                    }
                    break;
            };
        });

        //我参与的项目
        table.render({
            elem: '#projectTable'
            ,url: 'http://localhost:8080/task/myproject' //数据接口
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增,
            ,cols: [[
                {field:'projectCode',width:'30%',title:'项目代号',sort:true},
                {field:'projectName',width:'30%',title:'项目名称',sort:true},
                ,{field:'projectEndDate',width:'20%',minWidth: 80,title:'截止时间',sort:true}
                ,{field:'projectStatus',width:'20%',minWidth: 80,title:'状态',sort:true}
            ]]
            ,done:function (res, curr, count) {
                element.init();
            }
        });

        //我的代办事项
        table.render({
            elem: '#todoTable'
            ,url: 'http://localhost:8080/todo/mytodo' //数据接口
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增,
            ,cols: [[
                {field:'todoEndDate',width:'25%',minWidth: 100,title:'截止日期',sort:true}
                ,{field:'todoPriority',width:'20%',minWidth: 80,title:'级别',sort:true}
                ,{field:'todoName',width: '35%', minWidth: 100,title:'代办标题',sort:true}
                ,{field:'todoStatus',width: '20%', minWidth: 100,title:'状态',sort:true}
            ]]
        });

        form.on('submit(create_bug)',function (obj) {
            //获取表单数据
            var field = obj.field;
            //获取下拉框的值
            field.bugProjectCode=bugProjectCode;
            field.bugPriority=bugPriority;
            //获取多选下拉框的值
            field.assginedToSelect=formSelects.value('assginedToSelect','valStr');
            //获取当前时间并格式化yyyy-MM-dd HH:mm:ss
            var myDate=new Date();
            var nowDate=myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+
                myDate.getDate()+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds();
            field.bugCreateDate=nowDate;
            //获取单选框的值
            // field.type_edit=$('#teamStatus_edit input[name="type_edit"]:checked ').val()
            $.ajax({
                url: 'http://localhost:8080/bug/create',
                data: field,
                contentType: "application/x-www-form-urlencoded",
                type: 'POST',
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) {
                    if(data.status == "success") {
                        layer.msg('创建问题单成功', {
                            icon: 1,
                            time: 2000
                        }, function() {
                            layer.close(bugAdd);
                            table.reload('bugTable',{
                                url:'http://localhost:8080/bug/list'
                            })
                        });
                    } else {
                        layer.msg(data.data.errMsg, {
                            icon: 5,
                            time:2000
                        });
                    }
                }
            });
            return false;
        });

        form.on('submit(edit_bug)',function (obj) {
            //获取表单数据
            var field = obj.field;
            //获取下拉框的值
            field.bugPriority_edit=bugPriority;
            field.id=bugId;
            //获取多选下拉框的值
            field.assginedToSelect_edit=formSelects.value('assginedToSelect_edit','valStr');
            //获取当前时间并格式化yyyy-MM-dd HH:mm:ss
            var myDate=new Date();
            var nowDate=myDate.getFullYear()+"-"+(myDate.getMonth()+1)+"-"+
                myDate.getDate()+" "+myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds();
            field.bugCreateDate_edit=nowDate;
            //获取单选框的值
            // field.type_edit=$('#teamStatus_edit input[name="type_edit"]:checked ').val()
            $.ajax({
                url: 'http://localhost:8080/bug/update',
                data: field,
                contentType: "application/x-www-form-urlencoded",
                type: 'POST',
                xhrFields: {
                    withCredentials: true
                },
                success: function(data) {
                    if(data.status == "success") {
                        layer.msg('修改问题单成功', {
                            icon: 1,
                            time: 2000
                        }, function() {
                            layer.close(bugEdit);
                            table.reload('bugTable',{
                                url:'http://localhost:8080/bug/list'
                            })
                        });
                    } else {
                        layer.msg(data.data.errMsg, {
                            icon: 5,
                            time:2000
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
<!--修改问题单-->
<div style="display: none;" id="bug_edit">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>所属项目
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugProjectCode_edit" name="bugProjectCode_edit" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" disabled title="所属项目不允许修改">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>优先级
                    </label>
                    <div class="layui-input-inline">
                        <select name="bugPriority_edit" id="bugPriority_edit" lay-filter="bugPrioritySelect_edit" required lay-verify="required">
                            <option value=""></option>
                            <option value="较低">较低</option>
                            <option value="一般">一般</option>
                            <option value="较高">较高</option>
                            <option value="最高">最高</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>当前指派
                    </label>
                    <div class="layui-input-block">
                        <select name="assginedToSelect_edit" xm-select="assginedToSelect_edit" required lay-verify="required" xm-select-skin="default" xm-select-max="1">
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>Bug标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugName_edit" name="bugName_edit" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" disabled title="问题单标题不允许修改">
                    </div>
                </div>
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label">-->
                        <!--<span class="x-red">*</span>关键字-->
                    <!--</label>-->
                    <!--<div class="layui-input-inline">-->
                        <!--<input type="text" id="bugKeyword_edit" name="bugKeyword_edit" required="" lay-verify="required"-->
                               <!--autocomplete="off" class="layui-input" placeholder="请用逗号分开">-->
                    <!--</div>-->
                <!--</div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>截止日期
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugEndDate_edit" name="bugEndDate_edit" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" placeholder="yyyy-MM-dd HH:mm:ss">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>重现步骤</label>
                    <div class="layui-input-block">
                        <textarea id="bugStep_edit" name="bugStep_edit" class="layui-textarea" placeholder="请输入内容" ></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                    </label>
                    <button  class="layui-btn layui-btn-radius layui-btn-fluid" lay-filter="edit_bug" lay-submit="">
                        修改
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--添加问题单-->
<div style="display: none;" id="bug_add">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>所属项目
                    </label>
                    <div class="layui-input-inline">
                        <select name="bugProjectCode" id="bugProjectCode" lay-filter="bugProjectCodeSelect">
                            <option value=""></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>优先级
                    </label>
                    <div class="layui-input-inline">
                        <select name="bugPriority" id="bugPriority" lay-filter="bugPrioritySelect" required lay-verify="required">
                            <option value=""></option>
                            <option value="较低">较低</option>
                            <option value="一般">一般</option>
                            <option value="较高">较高</option>
                            <option value="最高">最高</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>当前指派
                    </label>
                    <div class="layui-input-block">
                        <select name="assginedToSelect" xm-select="assginedToSelect" required lay-verify="required" xm-select-skin="default" xm-select-max="1">
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>Bug标题
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugName" name="bugName" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="bugKeyword" class="layui-form-label">
                        <span class="x-red">*</span>关键字
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugKeyword" name="bugKeyword" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" placeholder="请用逗号分开">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>截止日期
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="bugEndDate" name="bugEndDate" required="" lay-verify="required"
                               autocomplete="off" class="layui-input" placeholder="yyyy-MM-dd HH:mm:ss">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>重现步骤</label>
                    <div class="layui-input-block">
                        <textarea id="bugStep" name="bugStep" class="layui-textarea" placeholder="请输入内容" ></textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                    </label>
                    <button  class="layui-btn layui-btn-radius layui-btn-fluid" lay-filter="create_bug" lay-submit="">
                        创建
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
</html>